#!/usr/bin/env bash

# ----------------------------------------------------------------------
# Filename	:  03-userbash-hdzx.sh
# Version	:  1.0
# Date		:  2020/05/14
# Author	:  Lz
# Email		:  lz843723683@gmail.com
# History	:     
#             Version 1.0, 2020/05/14
# Function	:   packages - 05.测试安全四级-默认系统帐号禁用
# Out		:        
#              0 => TPASS
#              1 => TFAIL
#              other=> TCONF
# ----------------------------------------------------------------------

## TODO : 测试收尾清除工作
#
UserBashClean_FTHDZX(){
	return $TPASS
}


## TODO: 调用程序退出函数
#    In: $1 => 调用脚本结果值
UserBashExit_FTHDZX(){
        # 调用退出函数，其中调用了clean相关函数
	Exit_FTLIB ${1}
}


## TODO: 用户界面
#
UserBashUSAGE_FTHDZX(){
	USAGE_FTLIB "华电众信版本 - Shell环境使用bash"
}


## TODO : 测试前的初始化 
#  Out  : 
#         0 => TPASS
#         1 => TFAIL
#         other=> TCONF
UserBashInit_FTHDZX(){
        # 调用初始化函数
	Init_FTLIB "UserBashClean_FTHDZX"
        # 调用用户界面函数
 	UserBashUSAGE_FTHDZX
}


## TODO ：Shell环境使用bash
#
UserBashTest01_FTHDZX(){
	local userarr=(root sysadm secadm audadm)
        local flag="/bin/bash"
	local passwdfile="/etc/passwd"

	local ret="$TPASS"
	# 非特定用户
	local user=""
	for user in ${userarr[@]}
	do
		echo "cat $passwdfile | grep "$user""
		cat $passwdfile | grep "^$user"
		cat $passwdfile | grep "^$user" | grep -q "$flag"
		if [ $? -eq 0 ];then
			OutputRet_FTLIB ${TPASS}
        		RetParse_FTLIB "用户 $user Shell设置为 $flag" "False"
		else
			OutputRet_FTLIB ${TFAIL}
        		RetParse_FTLIB "用户 $user Shell设置为 $flag" "False"
		fi
	done
}


## TODO : Main
#  Out  : 
#         0 => TPASS
#         1 => TFAIL
#         other => TCONF
UserBashMain_FTHDZX(){
	UserBashInit_FTHDZX

	UserBashTest01_FTHDZX

	return ${TPASS}	
}

UserBashMain_FTHDZX
UserBashExit_FTHDZX $?
